<cfif thisTag.ExecutionMode is 'start'>
   <!--- Start tag processing --->

	<cfif structKeyExists(attributes, "objName")>
		<cfset variables.objName = attributes.objName>
	<cfelse>
		<cfthrow message="The attribute objName must be defined">
	</cfif>

	<cfif structKeyExists(attributes, "cacheUntil")>
		<cfset variables.cacheUntil = attributes.cacheUntil>
	<cfelse>
		<cfset variables.cacheUntil = "">
	</cfif>

	<cfif structKeyExists(attributes, "lastUpdated")>
		<cfset variables.lastUpdated = attributes.lastUpdated>
	<cfelse>
		<cfset variables.lastUpdated = "">
	</cfif>
	
	<cfif structKeyExists(attributes, "createdDate")>
		<cfset variables.createdDate = attributes.createdDate>
	<cfelse>
		<cfset variables.createdDate = now()>
	</cfif>	

	<cfif structKeyExists(attributes, "flush")>
		<cfif attributes.flush eq 'true'>
			<cfset variables.flush = true>
		<cfelse>
			<cfset variables.flush = false>
		</cfif>
	<cfelse>
		<cfset variables.flush = false>
	</cfif>
	
	<!--- noCache indicates just process the page as usual, and don't cache anything --->
	<cfif structKeyExists(attributes, "noCache")>
		<cfif attributes.noCache eq 'true'>
			<cfset variables.noCache = true>
		<cfelse>
			<cfset variables.noCache = false>
		</cfif>
	<cfelse>
		<cfset variables.noCache = false>
	</cfif>	
	
	<!--- siteOffline indicates that nothing between the tags should be executed.  Serve up the cached version if it's there, otherwise show an error --->
	<cfif structKeyExists(attributes, "siteOffline")>
		<cfif attributes.siteOffline eq 'true'>
			<cfset variables.siteOffline = true>
		<cfelse>
			<cfset variables.siteOffline = false>
		</cfif>
	<cfelse>
		<cfset variables.siteOffline = false>
	</cfif>		
	
	<cfif variables.lastUpdated eq ''>		
		<cfset variables.result = application.objectCache.retrieveObject("#variables.objName#")>
	<cfelse>		
		<cfset variables.result = application.objectCache.retrieveObjectIfCurrent(objName = #variables.objName#, compareDate = #variables.lastUpdated#)>
	</cfif>
	<cfif structKeyExists(variables, 'result') AND variables.result eq '' AND variables.siteOffline eq 'true'>
		
		<cfoutput>Page not currently available</cfoutput>
		<cfexit method="exitTag">
	</cfif>
	
	<cfif structKeyExists(variables, 'result') AND variables.result neq '' AND variables.flush eq false AND variables.noCache eq false>		
		<cfoutput>#variables.result# <!-- Page retrieved from cache at #now()# --></cfoutput>
		<cfexit method="exitTag">
	</cfif>	
<cfelse>
   <!--- End tag processing --->	  
	<cfif ((NOT structKeyExists(variables, 'result')) OR variables.result eq '') OR variables.flush eq true OR variables.noCache eq true>	
		<cfset theGeneratedContent = thisTag.GeneratedContent>
		<cfif variables.noCache eq false>
			<cfif variables.cacheUntil neq ''>				
				<cfset temp = application.objectCache.addObject(objName = #variables.objName#, objVal = #theGeneratedContent#, cacheUntil = #variables.cacheUntil#, createdDate = #variables.createdDate#)>
			<cfelse>				
				<cfset temp = application.objectCache.addObject(objName = #variables.objName#, objVal = #theGeneratedContent#, createdDate = #variables.createdDate#)>
			</cfif>
		</cfif>

	</cfif>
</cfif>